package values.product
{
import flash.errors.IllegalOperationError;
import flash.utils.Dictionary;

/**
 * ProductTemplateValueList
 * @author jliang
 *
 */
public class ProductTemplateValueList
{
	private static var list:Dictionary = new Dictionary(true); /* ItemTemplateValue */
	
	public function get products():Dictionary
	{
		return list;
	}
	
	[Data(type="mapping", 
		   mapping="product", 
		   ref="values.product.ProductTemplateValue",
		   way="one_to_more",
		   object="flash.utils.Dictionary",
           key="@key")]
	public function set products(value:Dictionary):void
	{
		list = value;
	}
	
	public static function get productList():Dictionary
	{
		return list;
	}
	
	public static function getByKey(key:String):ProductTemplateValue
	{
		var product:ProductTemplateValue = list[key];
		if (!product)
		{
			throw new IllegalOperationError("Cannot find <" + key + "> product. Please check data configuration.");
		}
		return product;
	}
}
}



